kubernetes集群在生产过程中,不同类型的应用对资源的需求是不一样的,比如数据库需要高IO缓存的节点,CPU密集型的需要cpu处理性能更强的节点,内存密集型的需要更高效的内存节点,所以我们在一个生产kubernetes集群中会包含多种与应用需求不同资源的节点类型,得以让硬件资源更充分的利用,解决这一需求,第一,我们可以给节点打label,让同类型的应用被调度到同类型的节点中去,这种方式需要再每个控制器的Pod中使用selector配置node的label,让该控制器的pod调度到匹配到的节点中;第二,为node设置污点,让应用不可调度,再给想要调度到这些污点的应用设置亲和性,允许设置亲和性的pod被调度到污点node,下面篇幅主要讲改方法的配置过程
1.为node打污点
1 | $ [K8sPro0][已切换至生产环境,请注意你的操作] kubectl taint node 192-168-137-211 application=stateless:NoSchedule |
2.配置redash-server 亲和性toleration
在控制器的pod的spec下配置toleration
1 | tolerations: |
每个污点有一个1
2
3这里主要对亲和性字段做一些说明 ```key```个```value```是设置污点的key和value,```effect``` 是设置污点的作用(NoSchedule/PreferNoSchedule/NoExecute) ```operator``` 是 ```Exists```(这种情况下就不用指定 value),或者 ```operator``` 是 ```Equal``` 并且所有的 value 都相等
# 3.验证
$ [K8sPro0][已切换至生产环境,请注意你的操作] kubectl get pod –all-namespaces -owide |grep -E “192-168-137-211|192-168-137-213”
redash redash-server-7db7f689bf-hlp96 1/1 Running 0 33m 10.244.6.6 192-168-137-211 1
2
# 取消污点
kubectl taint nodes 192-168-137-211 192-168-137-212 192-168-137-213 application:NoSchedule-`
- 本文作者: ChuLinx
- 本文链接: http://yoursite.com/2019/11/30/Kubernetes 搞懂污点和亲和性/
- 版权声明: 本博客所有文章除特别声明外,均采用 MIT 许可协议。转载请注明出处!